/*
package com.example.demo.web;

import com.example.demo.mapper.CategoryMapper;
import com.example.demo.pojo.Category;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class CategoryController {

    @Autowired
    CategoryMapper categoryMapper;

    @RequestMapping("/listCategory")
    public String listCategory(Model m, @RequestParam(value = "start", defaultValue = "0")int start, @RequestParam(value = "size", defaultValue = "5")int size) throws Exception {
        PageHelper.startPage(start, size);
        List<Category> cs = categoryMapper.findall();
        PageInfo<Category> page = new PageInfo<>(cs);
        m.addAttribute("page", page);
        return "listCategory";
    }

    @RequestMapping("/addCategory")
    public String addCategory(Category category) {
        System.out.println("新增的name：" + category.getName());
        categoryMapper.addCategory(category);
        return "redirect:listCategory";
    }

    @RequestMapping("/editCategory")
    public String editCategory(int id, Model m) {
        System.out.println("编辑的id：" + id);
        Category c = categoryMapper.getCategory(id);
        m.addAttribute("category", c);
        return "editCategory";
    }

    @RequestMapping("/updateCategory")
    public String updateCategory(Category category) {
        System.out.println("更新的id：" + category.getId() + "，更新的name：" + category.getName());
        categoryMapper.updateCategory(category);
        return "redirect:listCategory";
    }
}
 */
